package mo.offer_special;

public class L005 {

    public int maxProduct(String[] words) {
        int length = words.length;
        int[] masks = new int[length];
        for (int i = 0; i < length; i++) {
            String word = words[i];
            for (int j = 0; j < word.length(); j++) {
                masks[i] |= 1 << (word.charAt(j) - 'a');
            }
        }
        int max = 0;
        for (int i = 0; i < length; i++) {
            for (int j = i+1; j < length; j++) {
                if ((masks[i] & masks[j]) == 0) {
                    max = Math.max(max, words[j].length() * words[i].length());
                }
            }
        }
        return max;
    }

}
